package robocup.component.speechacts.coachlanguage;

import java.util.LinkedList;

public class Rule {

  // private String ruleName = "";

  private Condition             condition     = null;

  private IdList                idList        = null;

  private LinkedList<Directive> directiveList = new LinkedList<Directive>();

  private LinkedList<Rule>      ruleList      = new LinkedList<Rule>();

  public void addDirective(final Directive direc) {

    this.directiveList.add(direc);
  }

  public void addRule(final Rule rule) {

    this.ruleList.add(rule);
  }

  public Condition getCondition() {

    return this.condition;
  }

  public void setCondition(final Condition condition) {

    this.condition = condition;
  }

  public LinkedList<Directive> getDirectiveList() {

    return this.directiveList;
  }

  public void setDirectiveList(final LinkedList<Directive> directiveList) {

    this.directiveList = directiveList;
  }

  public LinkedList<Rule> getRuleList() {

    return this.ruleList;
  }

  public void setRuleList(final LinkedList<Rule> ruleList) {

    this.ruleList = ruleList;
  }

  // public String getRuleName() {
  // return ruleName;
  // }
  //
  // public void setRuleName(String ruleName) {
  // this.ruleName = ruleName;
  // }

  public IdList getIdList() {

    return this.idList;
  }

  public void setIdList(final IdList idList) {

    this.idList = idList;
  }

  @Override
  public String toString() {

    if (this.idList == null) {
      final StringBuffer buf = new StringBuffer();

      buf.append(" (" + this.condition.toString());

      for (final Directive dir : this.directiveList) {
        buf.append(dir.toString());
      }

      for (final Rule ru : this.ruleList) {
        buf.append(ru.toString());
      }

      buf.append(")");

      return buf.toString();
    }
    else {
      return this.idList.toString();
    }

  }

}
